<?php

class Users {
    private $id;
    private $username;
    private $password;
    private $realname;
    private $jenkel;
    private $addr;
    private $province;
    private $kabkota;
    private $dob;
    private $description;

    public function __construct($_id, $_username, $_password, $_realname, $_jenkel, $_addr, $_province, $_kabkota, $_dob, $_description) {
        $this->id = $_id;
        $this->username = $_username;
        $this->password = $_password;
        $this->realname = $_realname;
        $this->jenkel = $_jenkel;
        $this->addr = $_addr;
        $this->province = $_province;
        $this->kabkota = $_kabkota;
        $this->dob = $_dob;
        $this->description = $_description;
    }

    public function getId() {
        return $this->id;
    }

    public function getUsername() {
        return $this->username;
    }

    public function getPassword() {
        return $this->password;
    }

    public function getRealname() {
        return $this->realname;
    }

    public function getJenkel() {
        return $this->jenkel;
    }

    public function getAddr() {
        return $this->addr;
    }

    public function getProvince() {
        return $this->province;
    }

    public function getKabkota() {
        return $this->kabkota;
    }

    public function getDob() {
        return $this->dob;
    }

    public function getDescription() {
        return $this->description;
    }

    public static function loads() {
        $result = mysql_query("select id,username,password,realname,jenkel,
            addr,province_id,kabkota_id,dob,description from tuser");
        $users = array();
        while ($row = mysql_fetch_array($result)) {
            $user = new Users($row['id'],$row['username'],$row['password'],
                    $row['realname'],$row['jenkel'],$row['addr'],
                    Province::load($row['province_id']), KabKota::load($row['kabkota_id']),
                    $row['dob'],$row['description']);
            array_push($users, $user);
        }
        return $users;
    }
    
    public static function loadsJSON(){
        return json_encode(arrayOfObjectToArray(Users::loads()));
    }

}

?>
